# Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>

pkgname=gnome-remote-desktop
pkgver=40.1
pkgrel=1
pkgdesc="GNOME Remote Desktop server"
url="https://wiki.gnome.org/Projects/Mutter/RemoteDesktop"
arch=(x86_64)
license=(GPL2)
depends=(cairo freerdp glib2 pipewire systemd libvncserver libsecret libnotify
         dconf fuse3 libxkbcommon)
makedepends=(git meson)
checkdepends=(xorg-server-xvfb python-dbus python-gobject mutter
              pipewire-media-session)
groups=(gnome)
_commit=fcff89c168a35471a014453f15b13c78eba076a5  # tags/40.1^0
source=("git+https://gitlab.gnome.org/GNOME/gnome-remote-desktop.git#commit=$_commit")
sha256sums=('SKIP')

pkgver() {
  cd $pkgname
  git describe --tags | sed 's/-/+/g'
}

prepare() {
  cd $pkgname
}

build() {
  arch-meson $pkgname build
  meson compile -C build
}

check() (
  mkdir -p -m 700 "${XDG_RUNTIME_DIR:=$PWD/runtime-dir}"
  glib-compile-schemas "${GSETTINGS_SCHEMA_DIR:=$PWD/build/src}"
  export XDG_RUNTIME_DIR GSETTINGS_SCHEMA_DIR
  unset DBUS_SESSION_BUS_ADDRESS

  pipewire &
  _p1=$!

  pipewire-media-session &
  _p2=$!

  trap "kill $_p1 $_p2; wait" EXIT

  meson test -C build --print-errorlogs -t 2
)

package() {
  DESTDIR="$pkgdir" meson install -C build
}
